package chapter05

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test08_Praction
 * Package: chapter05
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-20
 *          Time: 16:26
 */

object Test08_Practice {
  def main(args: Array[String]): Unit = {

    //练习一
    val fun = (i: Int, s: String, c: Char) => {
      if (i == 0 && s == "" && c == '0') false else true
    }
    println(fun(0, "", '0')) //false
    println(fun(1, "", '0')) //true
    println(fun(0, "2", '0')) //true

    println("--------------------")
    //练习二
    def func(i:Int):String => (Char=>Boolean) ={
      def f1(s:String): Char=>Boolean ={
        def f2(c:Char):Boolean = {
          if (i == 0 && s == "" && c == '0') false else true
        }
        f2
      }
      f1
    }
    println(func(0)("")('0'))

    //匿名函数写法
    def func1(i:Int):String => (Char=>Boolean) ={
      s => c =>  if (i == 0 && s == "" && c == '0') false else true
    }
    println(func1(0)("")('0'))

    //柯里化
    def func2(i: Int)(s: String)(c: Char): Boolean = {
      if (i == 0 && s == "" && c == '0') false else true
    }
    println(func1(0)("")('0'))



  }

}
